package tools;
/**
* 
* @ClassName: tools
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Jarvis
* @date 20172017年3月17日 下午4:16:45
* 
*/
public class LinkedList {
	Node node,head,trail,current;
private class Node{
	public int data;
       //是双向的列表
	public Node next;
	public Node previous;
       //构造函数
	public Node(int data) {
		this.data=data;
	}
}
	
	public boolean isEmpty(){
		if(head!=null)
			return false;
		else {
			return true;
		}
	};
	public void add(int i) {
		Node node = new Node(i);
		
		if(isEmpty()){
			head = node;
			trail = node;

		}else{
			trail.next = node;
			node.previous = trail;
			trail=trail.next;

		}
	}
	public void display() {
		current = head;
		do{
			System.out.print(current.data + "\t");
			current = current.next;
		}while(current != null);
		System.out.println();
	}
	public void remove(int i) {
	//	node.previous.next=node.next;
	//  node.next.previous=node.previous;
	 current = head;
	 do{
		 if(current.data==i)
		 {if(current.next!= null){
	   		current.previous.next = current.next;
	  		current.next.previous = current.previous;
		 }else{
			 current.previous.next = null;
		 }
		 break;
		 }
		 current = current.next;
	 }while(true);
	   	
	}

}
